#include <iostream>
using std::cout;
using std::endl;

class Test
{};

class Point
{
public:
    Point(int x ,int y)
    : _ix(x)
    , _iy(y)
    {
        cout << "Point(int,int)" << endl;
    }

    Point(const Point & rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        cout << "Point(const Point &)" << endl;
    }
    
    Point & operator=(const Point & rhs){
        cout << "赋值运算符函数" << endl;
        this->_ix = rhs._ix;
        this->_iy = rhs._iy;
        return *this;
    }

    //this指针的类型Point * const this
    //对象调用成员函数，成员函数执行时
    //编译器会自动加入this指针作为函数的第一个参数
    //不要在参数列表中显式写出this指针
    void print(){
        //this指针一定指向本对象（此次调用成员函数的对象）
        /* cout << &this << endl; */
        /* this = new Point(1,2); */
        /* this->_ix = 100; */
        cout << "(" << this->_ix
            << "," << this->_iy
            << ")" << endl;
    }

    ~Point(){
        cout << "~Point()" << endl;
    }
private:
    int _ix;
    int _iy;
};

void test0(){
    int x = 1, y = 2;
    cout << &x << endl;
    cout << &(x = y) << endl;//赋值操作

    Point p1(2,5);
    Point p2(6,7);
    cout << &p1 << endl;
    cout << &(p1.operator=(p2)) << endl;//下一句的本质
    cout << &(p1 = p2) << endl;
    p1.print();
    p2.print();
}

int main(void){
    test0();
    return 0;
}
